package fr.cephb.lexyacc;
/** A node for a logical OR */
public class OrNode extends YNode {

	
	public OrNode(Node a,Node b)
		{
		super(a,b);
		}
	
	public String getName()
		{
		return "or";
		}
	/**
	 * @return true if one of the two nodes return java.lang.Boolean.TRUE
	 */
	@Override
	public Object eval(Context ctx)
		{
		Object o1 = at(0).eval(ctx);
		if(o1==null || !(o1 instanceof Boolean)) return null;
		if(Boolean.class.cast(o1)) return Boolean.TRUE;
		Object o2 = at(1).eval(ctx);
		if(o2==null || !(o2 instanceof Boolean)) return null;
		return Boolean.class.cast(o2);
		}

}
